package com.topwalk.datacollect.dao.imp;

import com.topwalk.datacollect.dao.TZcOtherDao;
import com.topwalk.datacollect.enumI.ServerEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public class TZcOtherDaoImpl implements TZcOtherDao {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public List<Map<String, Object>> findOther(String api, String taskId) {
        ServerEnum serverEnum = ServerEnum.getTypeByServerCode(api);
        String sql = "";
        switch (serverEnum){
            case VIDEO:
                sql = "select FLD_DEVICE_ID deviceID from t_zc_mtp_task where FLD_ID = ?";
                break;
            case DBEXCHANGELOG:
            case FILEEXCHANGELOG:
                sql = "SELECT task.taskid,deviceid,platID,info.innerLinkID AS linkID,bizID FROM \n" +
                        "(SELECT taskid,deviceid FROM t_zc_dtp_task WHERE taskid = ?) task\n" +
                        "LEFT JOIN \n" +
                        "(select taskID,platID,innerLinkID,bizID from t_zc_taskinfo) info \n" +
                        "ON task.taskid = info.taskID";
                break;
        }

        return jdbcTemplate.queryForList(sql,taskId);
    }
}
